import App from '@/App.vue'
import { createApp } from 'vue'
import gloablComponent from './components/index'
import router from './router'
import pinia from './stores'
import 'virtual:svg-icons-register'
import '@/styles/index.scss'
import 'bpmn-js/dist/assets/diagram-js.css'
import 'bpmn-js/dist/assets/bpmn-font/css/bpmn.css'
import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-codes.css'
import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.css'
import '@bpmn-io/properties-panel/dist/assets/properties-panel.css'

createApp(App)
  .use(pinia)
  .use(gloablComponent)
  .use(router)
  .directive('click-outside', {
    mounted(el, binding) {
      el.clickOutsideEvent = function (event: MouseEvent) {
        if (!(el === event.target || el.contains(event.target))) {
          binding.value(event, el)
        }
      }
      document.body.addEventListener('click', el.clickOutsideEvent)
    },
    unmounted(el) {
      document.body.removeEventListener('click', el.clickOutsideEvent)
    },
  })
  .mount('#app')
